constraint-editor: Improve display of constraints
authorMatthias Clasen <mclasen@redhat.com>
Wed, 18 Nov 2020 02:52:15 +0000 (21:52 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 18 Nov 2020 02:52:15 +0000 (21:52 -0500)
No need to go for ALGOL60 style operators when we
have Unicode.

demos/constraint-editor/constraint-editor.c

index 62af6e356fccd873be47c27ef47ef490ee1a97c6..ffbc6a15b03f05712f913b5b62a472bea3f329f4 100644 (file)
@@ -212,6 +212,22 @@ get_relation_nick (GtkConstraintRelation relation)
   return nick;
 }
 
+static const char *
+get_relation_display_name (GtkConstraintRelation relation)
+{
+  switch (relation)
+    {
+    case GTK_CONSTRAINT_RELATION_LE:
+      return "≤";
+    case GTK_CONSTRAINT_RELATION_EQ:
+      return "=";
+    case GTK_CONSTRAINT_RELATION_GE:
+      return "≥";
+    default:
+      return "?";
+    }
+}
+
 static GtkConstraintStrength
 get_strength (const char *id)
 {
@@ -347,7 +363,7 @@ constraint_editor_constraint_to_string (GtkConstraint *constraint)
 
   name = get_target_name (gtk_constraint_get_target (constraint));
   attr = get_attr_nick (gtk_constraint_get_target_attribute (constraint));
-  relation = get_relation_nick (gtk_constraint_get_relation (constraint));
+  relation = get_relation_display_name (gtk_constraint_get_relation (constraint));
 
   if (name == NULL)
     name = "[ ]";